package cs2114.alarmclock;

import student.TestCase;
import java.util.Iterator;

/**
 * // -------------------------------------------------------------------------
/**
 * Test the {@link Deque} Class.
 *
 *  @author Joe Acanfora
 *  @version Nov 16, 2011
 */
public class DequeTest extends TestCase
{
    //Fields---------------
    /**
     * testable deque
     */
    Deque<String> circle;
    /**
     * testable iterator
     */
    Iterator<String> ite;
    /**
     * testable item
     */
    String testA;
    /**
     * testable item
     */
    String testB;
    /**
     * testable item
     */
    String testC;
    /**
     * testable item
     */
    String testD;
    /**
     *
     */
    String testE;
    /**
     * Constructor
     */
    public DequeTest()
    {
        //Empty Constructor for testing
    }
    /**
     * Instantiates Variables for testing, runs before each test method.
     */
    public void setUp()
    {
        circle = new Deque<String>();
        ite = circle.iterator();
        testA = new String("A");
        testB = "B";
        testC = "C";
        testD = "D";
        testE = new String("E");
    }
    /**
     * Test the {@link Deque#enqueueAtRear(Object)} method.
     */
    public void testEnqueueAtRear()
    {
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testA);
        assertEquals(circle.size(), 3);
    }
    /**
     * Test the {@link Deque#peek()} method.
     */
    public void testPeek()
    {
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testB);
        circle.enqueueAtRear(testC);
        assertEquals(circle.peek(), testA);
    }
    /**
     * Test the {@link Deque#enqueueAtFront(Object)} method.
     */
    public void testEnqueueAtFront()
    {
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testB);
        circle.enqueueAtFront(testC);
        assertEquals(circle.peek(), testC);
        assertEquals(circle.size(), 3);
    }
    /**
     * Test the {@link Deque#clear()} method.
     */
    public void testClear()
    {
        circle.enqueueAtFront(testA);
        circle.enqueueAtFront(testB);
        circle.clear();
        assertEquals(circle.size(), 0);
    }
    /**
     * Test the {@link Deque#dequeueAtFront()} method.
     */
    public void testDequeueAtFront()
    {
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testB);
        circle.enqueueAtRear(testC);
        assertEquals(circle.dequeueAtFront(), testA);
        assertEquals(circle.size(), 2);
    }
    /**
     * Test the {@link Deque#toString()} method.
     */
    public void testToString()
    {
        circle.enqueueAtRear(testA);
        circle.enqueueAtRear(testB);
        circle.enqueueAtRear(testC);
        assertEquals(circle.toString(), "<A, B, C>");
        circle.clear();
        assertEquals(circle.toString(), "<>");
    }
}
